package com.liuhaozzu.zookeeper.zookeeper_app.acl;

import java.io.IOException;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.ZooDefs.Ids;

public class ACL2 {

	final static String PATH="/liuhaozzu-acl";
	public static void main(String[] args) throws Exception {
		ZooKeeper zk1=new ZooKeeper("hadoop1:2181",5000, null);
		zk1.addAuthInfo("digest", "foo:true".getBytes());
		zk1.create(PATH, "init".getBytes(), Ids.CREATOR_ALL_ACL, CreateMode.EPHEMERAL);
		
		ZooKeeper zk2=new ZooKeeper("hadoop1:2181",5000, null);
		zk2.addAuthInfo("digest", "foo:true".getBytes());
		System.out.println("zk2>>>>>>>"+zk2.getData(PATH, false, null));
		
		ZooKeeper zk3=new ZooKeeper("hadoop1:2181",5000, null);
		zk3.addAuthInfo("digest", "foo:false".getBytes());
		System.out.println(zk3.getData(PATH, false, null));
		
	}
}
